package com.gt.quality.apim.domain.vo;

import com.gt.quality.apim.domain.ApiParamInfo;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Data
public class ApiDataInfoVo implements Serializable {

    private Long id;

    /**
     * api名称
     */
    @NotNull
    @Max(value = 255, message = "名称过长")
    private String apiName;

    /**
     * api code
     */
    @NotNull
    @Max(value = 32, message = "非法Code")
    private String apiCode;

    /**
     *  请求方式: "POST|GET|PUT|DELETE"
     */
    @NotNull
    private String apiReqMethod;


    /**
     * api描述
     */
    private String apiDesc;

    /**
     * API地址:http://localhost:8080/test
     */
    @NotNull(message = "API地址不允许为空")
    private String apiUrl;

    /**
     * API请求参数-正常返回示例
     */
    private String apiSuccessResult;

    /**
     * API请求参数-异常返回示例
     */
    private String apiErrorResult;

    /**
     * API创建人
     */
    private String createBy;

    /**
     * API创建时间
     */
    private Date createTime;

    /**
     * 默认
     */
    private Integer apiQueryTimeout;

    public Integer getApiQueryTimeout() {
        if (apiQueryTimeout == null) {
            this.apiQueryTimeout = 30;
            return this.apiQueryTimeout;
        }
        return apiQueryTimeout;
    }

    /**
     * JSON : VIEW
     */
    private String apiRespType;


    /**
     * "application/json" : "application/x-www-form-urlencoded"
     */
    private String apiContentType;

    public String getApiRespType() {
        if (apiRespType == null) {
            this.apiRespType = "JSON";
            return this.apiRespType;
        }
        return apiRespType;
    }

    public String getApiContentType() {
        if (apiContentType == null) {
            this.apiContentType = "application/json";
            return this.apiContentType;
        }
        return apiContentType;
    }

    /**
     * 变量参数或者常量参数
     */
    private List<ApiParamInfo> apiParamInfoList;

}

